﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import flash.display.*;
    import reprise.controls.*;
    import flash.filters.*;
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.utils.*;

    public class PatientScrollItem extends reprise.controls.SimpleButton {

        private var m_detailPanel:UIComponent;
        private var m_readyPanel:UIComponent;
        private var m_infoPanel:UIComponent;
        private var m_background:UIComponent;
        private var m_petId:String;
        private var m_type:String;
        private var m_treatments:Array;
        private var m_timeLabel:Label;
        private var m_readyLabel:Label;
        private var m_imageDisplay:UIComponent;
        private var m_treatmentsDisplay:UIComponent;
        private var m_treatmentThumbs:Dictionary;
        private var m_yellowOutline:BitmapFilter;
        private var m_neededRoomsLabel:Label;
        private var m_lastTreatmentThumb:MovieClip;
        private var m_name:String;
        private var m_diseaseName:String;

        public function PatientScrollItem(_arg1:String, _arg2:String, _arg3:String, _arg4:Array, _arg5:String){
            this.m_petId = _arg1;
            this.m_name = _arg2;
            this.m_type = _arg3;
            this.m_treatments = _arg4;
            this.m_diseaseName = _arg5;
            this.m_treatmentThumbs = new Dictionary();
            this.m_yellowOutline = Filters.getFilter(Filters.YELLOW_OUTLINE);
        }
        override public function remove(... _args):void{
            removeEventListener(MouseEvent.MOUSE_OVER, this.handleMouseOver);
            removeEventListener(MouseEvent.MOUSE_OUT, this.handleMouseOut);
            removeEventListener(MouseEvent.CLICK, this.handleMouseClick);
            this.m_treatmentThumbs = null;
            super.remove();
        }
        public function get petId():String{
            return (this.m_petId);
        }
        public function setReadyText(_arg1:String):void{
            this.m_readyLabel.setLabel(_arg1);
        }
        public function setNeedRoomsText(_arg1:String):void{
            this.m_neededRoomsLabel.setLabel(_arg1);
        }
        public function setTimeLeft(_arg1:String):void{
            ((!((_arg1 == "0"))) && (this.m_timeLabel.setLabel(_arg1)));
        }
        public function showReady():void{
            removeEventListener(MouseEvent.MOUSE_OVER, this.handleMouseOver);
            removeEventListener(MouseEvent.MOUSE_OUT, this.handleMouseOut);
            removeEventListener(MouseEvent.CLICK, this.handleMouseClick);
            this.m_readyPanel.show();
            this.m_infoPanel.hide();
            this.m_detailPanel.hide();
            this.m_timeLabel.setLabel("");
        }
        public function hideReady():void{
            this.m_infoPanel.show();
            this.m_readyPanel.hide();
            addEventListener(MouseEvent.MOUSE_OVER, this.handleMouseOver);
            addEventListener(MouseEvent.MOUSE_OUT, this.handleMouseOut);
            if (this.m_lastTreatmentThumb){
                this.m_lastTreatmentThumb.filters = [];
                this.m_lastTreatmentThumb.alpha = 0.3;
            };
        }
        public function highlightCurrentTreatment(_arg1:String):void{
            var _local2:MovieClip = this.m_treatmentThumbs[_arg1];
            _local2.filters = [this.m_yellowOutline];
            this.m_lastTreatmentThumb = _local2;
        }
        override protected function initialize():void{
            addEventListener(MouseEvent.MOUSE_OVER, this.handleMouseOver);
            addEventListener(MouseEvent.MOUSE_OUT, this.handleMouseOut);
            addEventListener(MouseEvent.CLICK, this.handleMouseClick);
            addCSSClass("scrollItem");
            super.initialize();
        }
        override protected function createChildren():void{
            this.m_background = addComponent("scrollItemBackground");
            this.infoPanel();
            this.detailPanel();
            this.readyPanel();
        }
        private function infoPanel():void{
            this.m_infoPanel = addComponent("panelDisplay");
            var _local1:MovieClip = AssetsLibrary.getMovieClip(((this.m_type + this.m_diseaseName) + "Thumb"));
            this.m_imageDisplay = this.m_infoPanel.addComponent("imageDisplay");
            if (_local1){
                _local1.cacheAsBitmap = true;
                this.m_imageDisplay.addChild(_local1);
            } else {
                l((("e asset missing, linkage id: " + this.m_type) + "Thumb"));
            };
            var _local2:Label = Label(this.m_infoPanel.addComponent("typeLabelInfo", null, Label));
            _local2.setLabel(this.m_name);
            this.m_timeLabel = Label(this.m_infoPanel.addComponent("timerLabel", null, Label));
        }
        private function detailPanel():void{
            var _local3:UIComponent;
            var _local4:MovieClip;
            this.m_detailPanel = addComponent("panelDisplay");
            this.m_detailPanel.hide();
            this.m_treatmentsDisplay = this.m_detailPanel.addComponent("treatmentsDisplay");
            var _local1:int;
            while (_local1 < this.m_treatments.length) {
                _local3 = this.m_treatmentsDisplay.addComponent("treatmentLogoDisplay");
                _local4 = AssetsLibrary.getMovieClip((this.m_treatments[_local1].roomType + "Small"));
                if (_local4){
                    _local3.addChild(_local4);
                    this.m_treatmentThumbs[this.m_treatments[_local1].roomType] = _local4;
                };
                _local1++;
            };
            var _local2:Label = Label(this.m_detailPanel.addComponent("typeLabel", null, Label));
            _local2.setLabel(this.m_name);
            this.m_neededRoomsLabel = Label(this.m_detailPanel.addComponent("neededRoomsLabel", null, Label));
        }
        private function readyPanel():void{
            this.m_readyPanel = addComponent("panelDisplay");
            this.m_readyPanel.hide();
            this.m_readyPanel.addComponent("star");
            var _local1:Label = Label(this.m_readyPanel.addComponent("typeLabel", null, Label));
            _local1.setLabel(this.m_name);
            this.m_readyLabel = Label(this.m_readyPanel.addComponent("readyLabel", null, Label));
        }
        private function handleMouseOut(_arg1:MouseEvent):void{
            this.m_background.removeCSSClass("withTop");
            this.m_infoPanel.show();
            this.m_detailPanel.hide();
        }
        private function handleMouseOver(_arg1:MouseEvent):void{
            this.m_background.addCSSClass("withTop");
            this.m_infoPanel.hide();
            this.m_detailPanel.show();
        }
        private function handleMouseClick(_arg1:MouseEvent):void{
            dispatchEvent(new ViewCompEvent(ViewCompEvent.CLICK, this.m_petId));
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
